from google.appengine.ext import db
from google.appengine.ext import search  

##################################################################################
#                                                                                #
#                       Models                                                   #
#                                                                                #
##################################################################################

class CustomUser(db.Model):
  name = db.StringProperty()
  url = db.StringProperty()
  user = db.UserProperty()
  role = db.StringProperty()

class LinkCategory(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  imagekey = db.StringProperty()
  structure = db.StringProperty()
  description=db.TextProperty()
  order = db.IntegerProperty(default=0)

class Unit(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  imagekey = db.StringProperty()
  structure = db.StringProperty()
  description=db.TextProperty()
  order = db.IntegerProperty(default=0)

class Link(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  category = db.ReferenceProperty(LinkCategory)
  unit = db.ReferenceProperty(Unit)
  imagekey = db.StringProperty()
  linktype = db.StringProperty()
  href = db.StringProperty()
  difficulty = db.StringProperty()
  activity = db.StringProperty()
  description=db.TextProperty()
  order = db.IntegerProperty(default=0)



class ArticleCategory(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  description=db.TextProperty()
  articlescounter = db.IntegerProperty(default=0)

class Article(search.SearchableModel):
  title = db.StringProperty()
  url = db.StringProperty()
  category = db.ReferenceProperty(ArticleCategory)
  imagekey = db.StringProperty()
  alignimage = db.StringProperty()
  body=db.TextProperty()
  pub_date=db.DateTimeProperty(auto_now_add=True)


class File(db.Model):
  code=db.StringProperty()
  bytes_content=db.BlobProperty()
  mime=db.StringProperty()
  extension=db.StringProperty()
  size=db.IntegerProperty()
  width=db.IntegerProperty()
  height=db.IntegerProperty()
  status=db.StringProperty()
  service = db.StringProperty()
  imagetype = db.StringProperty(default='normal')
  pub_date=db.DateTimeProperty(auto_now=True, auto_now_add=True)
  filekey=db.StringProperty()


class Todo(search.SearchableModel):
  title = db.StringProperty()
  description = db.TextProperty()
  done = db.BooleanProperty(default=False)
  department = db.StringProperty()
  locker = db.StringProperty(default='')
  pub_date=db.DateTimeProperty(auto_now_add=True)
  creator = db.StringProperty()

class Configuration(db.Model):
  name = db.StringProperty()
  value = db.StringProperty()

class Comment(db.Model):
  author = db.StringProperty()
  pub_date = db.DateTimeProperty(auto_now_add=True)
  message = db.TextProperty()
  email = db.StringProperty()
  commenttype = db.StringProperty()
  keyreference = db.StringProperty()

